{% include "iframe_header" %}


<div class="layuimini-container layuimini-page-anim">
    <div class="layuimini-main">

        <fieldset class="table-search-fieldset">
            <legend>搜索信息</legend>
            <div style="margin: 10px 10px 10px 10px">
                <form class="layui-form layui-form-pane" action="" lay-filter="searchForm">
                    <div class="layui-form-item">

                        <div class="layui-inline">
                            <label class="layui-form-label">用户ID</label>
                            <div class="layui-input-inline">
                                <input type="hidden" name="symbol" class="layui-input">
                                <input type="text" name="user_id" autocomplete="off" class="layui-input">
                            </div>
                        </div>


                        <div class="layui-inline">
                            <label class="layui-form-label">业务订单号</label>
                            <div class="layui-input-inline">
                                <input type="text" name="business_id" autocomplete="off" class="layui-input">
                            </div>
                        </div>

                        <div class="layui-inline layui-form-item">
                            <label class="layui-form-label">状态</label>
                            <div class="layui-input-inline">
                                <select name="status">
                                    <option value="">全部</option>
                                    <option value="0">冻结</option>
                                    <option value="1">已解冻</option>
                                </select>
                            </div>
                        </div>
                        
                        
                        <div class="layui-inline">
                            <button type="submit" class="layui-btn layui-btn-primary"  lay-submit lay-filter="data-search-btn"><i class="layui-icon"></i> 搜 索</button>
                            <button type="reset" class="layui-btn layui-btn-primary">清空</button>
                        </div>
                    </div>
                </form>
            </div>
        </fieldset>

        <script type="text/html" id="toolbarDemo">
            <div class="layui-btn-container" style="display: none;">
                <button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn" lay-event="add"> 添加 </button>
                <button class="layui-btn layui-btn-sm layui-btn-danger data-delete-btn" lay-event="delete"> 删除 </button>
            </div>
        </script>

        <table class="layui-hide" id="assetsFreezeTable" lay-filter="assetsFreezeTableFilter"></table>

        <script type="text/html" id="assetsFreezeTableBar">
            {{#  if(d.status == 0){ }}
                <!-- <a class="layui-btn layui-btn-normal layui-btn-xs unfreeze" lay-event="unfreeze">解冻</a> -->
            {{#  } }}
        </script>

    </div>
</div>


<script>
    layui.use(['form', 'table','element'], function () {
        var $ = layui.jquery,
            form = layui.form,
            table = layui.table;

        table.render({
            elem: '#assetsFreezeTable',
            url: '/admin/user/assets/freeze?api=1',
            //toolbar: '#toolbarDemo',
            defaultToolbar: ['filter', 'exports', 'print', {
                title: '提示',
                layEvent: 'LAYTABLE_TIPS',
                icon: 'layui-icon-tips'
            }],
            where: {"searchParams": {% .search | json %}},
            cols: [[
                {type: "checkbox", width: 50},
                {field: 'user_id', title: '用户ID'},
                {field: 'symbol', title: '资产'},
                {field: 'amount', title: '初始冻结', templet: function(d){
                    return utils.format_num(d.amount);
                }},
                {field: 'freeze_amount', title: '剩余冻结', templet: function(d){
                    return utils.format_num(d.freeze_amount);
                }},
                {field: 'business_id', title: '业务订单号', width: 200},
                {field: 'op_type', title: '类型', templet: function(d){
                    if(d.op_type == "trade") {
                        return "交易";
                    }
                    if(d.op_type == "deposit") {
                        return "充值";
                    }
                    if(d.op_type == "withdraw") {
                        return "提现";
                    }
                    if(d.op_type == "transfer") {
                        return "转账";
                    }
                }},
                {field: 'status', title: '状态', templet: function(d){
                    if(d.status == 1) {
                        return "已解冻";
                    }
                    return "冻结";
                }},
                {field: 'info', title: '备注'},
                {field: 'create_time', width: 180, title: '创建时间', templet: function(d){
                    return utils.format_timestamp(d.create_time*1000);
                }},
                {field: 'update_time', width: 180, title: '更新时间', templet: function(d){
                    return utils.format_timestamp(d.update_time*1000);
                }}
            ]],
            limits: [10, 15, 20, 25, 50, 100],
            limit: 15,
            page: true,
            skin: 'line'
        });

        
        

        // 监听搜索操作
        form.on('submit(data-search-btn)', function (data) {
            var result = JSON.stringify(data.field);
            //执行搜索重载
            table.reload('assetsFreezeTable', {
                page: {
                    curr: 1
                }
                , where: {
                    searchParams: result
                }
            }, 'data');

            return false;
        });


        //监听表格复选框选择
        table.on('checkbox(assetsFreezeTableFilter)', function (obj) {
            console.log(obj)
        });

        table.on('tool(assetsFreezeTableFilter)', function (obj) {
            var data = obj.data;
            if (obj.event === 'edit') {
                return false;
            } else if (obj.event === 'freeze') {
                
            } else if (obj.event === 'assets_log') {
                
            }
        });

        form.val("searchForm", JSON.parse({% .search | json %}));
        form.render();
    });
</script>

{% include "iframe_footer" %}